﻿package mortal.game.utils
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import com.gengine.debug.*;
    import com.gengine.manager.*;
    import extend.language.*;
    import extend.php.*;
    import flash.net.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.copy.QuestionCopy.data.*;
    import mortal.game.view.platform.*;
    import mortal.game.view.vip.*;
    import mortal.mvc.core.*;

    public class GameUtil extends Object
    {
        private static var activeRePayType:int = 2;

        public function GameUtil()
        {
            return;
        }// end function

        public static function gotoRecharge(param1:int) : void
        {
            if (PlatformConst.isQQ())
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ShopOpenQPointExchangeWin, 1));
                return;
            }
            var _loc_2:* = ParamsConst.instance.payUrl;
            var _loc_3:* = new URLRequest(_loc_2);
            navigateToURL(_loc_3, "_blank");
            PHPSender.sendToURLByPHP(SenderType.RechargeFrom, param1.toString(), true);
            return;
        }// end function

        public static function QQVipStatistics(param1:int) : void
        {
            PHPSender.sendToURLByPHP(SenderType.RechargeFrom, param1.toString(), true);
            return;
        }// end function

        public static function gotoAplyZiZuan() : void
        {
            if (PlatformConst.isQQ())
            {
                MsgManager.showRollTipsMsg(Language.getString(20688));
                return;
            }
            var _loc_1:* = ParamsConst.instance.yyZiZuanUrl;
            var _loc_2:* = new URLRequest(_loc_1);
            navigateToURL(_loc_2, "_blank");
            return;
        }// end function

        public static function gotoPlatformVipHelp() : void
        {
            var _loc_1:* = ParamsConst.instance.platformVipHelpUrl;
            var _loc_2:* = new URLRequest(_loc_1);
            navigateToURL(_loc_2, "_blank");
            return;
        }// end function

        public static function gotoPlatformVipUpgrade() : void
        {
            var _loc_1:* = ParamsConst.instance.platformVipUpgradeUrl;
            var _loc_2:* = new URLRequest(_loc_1);
            navigateToURL(_loc_2, "_blank");
            return;
        }// end function

        public static function gotoPlatformVerific() : void
        {
            var _loc_1:* = ParamsConst.instance.platformMobileVerificUrl;
            var _loc_2:* = new URLRequest(_loc_1);
            navigateToURL(_loc_2, "_blank");
            return;
        }// end function

        public static function gotoQQVipMonthUpgrade() : void
        {
            var _loc_1:String = null;
            var _loc_2:URLRequest = null;
            if (ParamsConst.instance.enterType == 1)
            {
                _loc_1 = ParamsConst.instance.QQVipMonthUrl;
                _loc_2 = new URLRequest(_loc_1);
                navigateToURL(_loc_2, "_blank");
            }
            else if (ParamsConst.instance.enterType == 2)
            {
                Log.debugMsg(LogType.other, "调用Js openVipGift");
                BrowerManager.instance.asCallJsFun("openVipGift");
            }
            return;
        }// end function

        public static function gotoQQVipYearUpgrade() : void
        {
            var _loc_1:String = null;
            var _loc_2:URLRequest = null;
            if (ParamsConst.instance.enterType == 1)
            {
                _loc_1 = ParamsConst.instance.QQVipYearUrl;
                _loc_2 = new URLRequest(_loc_1);
                navigateToURL(_loc_2, "_blank");
            }
            else if (ParamsConst.instance.enterType == 2)
            {
                Log.debugMsg(LogType.other, "调用Js openVipGift");
                BrowerManager.instance.asCallJsFun("openVipGift");
            }
            return;
        }// end function

        public static function gotoQQVipGuanwang() : void
        {
            var _loc_1:String = null;
            var _loc_2:URLRequest = null;
            if (ParamsConst.instance.enterType == 2)
            {
                _loc_1 = ParamsConst.instance.QQVipGuanWangUrl;
                _loc_2 = new URLRequest(_loc_1);
                navigateToURL(_loc_2, "_blank");
            }
            return;
        }// end function

        public static function gotoQQActiveRePay(param1:int = 2) : void
        {
            var _loc_3:URLVariables = null;
            activeRePayType = param1;
            var _loc_2:* = ParamsConst.instance.QQBuyUrl;
            if (_loc_2)
            {
                _loc_3 = new URLVariables();
                _loc_3.activeType = 1;
                PHPGetter.getUrlValue(_loc_2, _loc_3, onGotoQQActiveRePay);
            }
            return;
        }// end function

        private static function onGotoQQActiveRePay(param1:String) : void
        {
            var obj:Object;
            var token:String;
            var str:* = param1;
            try
            {
                obj = JSON.parse(str);
                if (obj && obj.token)
                {
                    token = obj.token;
                    BrowerManager.instance.asCallJsFunParam("openVipActiveGift", token, activeRePayType);
                }
            }
            catch (e:Error)
            {
            }
            return;
        }// end function

        public static function getExpAdditionStr(param1:Boolean = true, param2:Boolean = true) : String
        {
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_9:Array = null;
            var _loc_10:TQuestionRewards = null;
            var _loc_3:String = "";
            if (param1)
            {
                _loc_5 = VipUtil.getCurValueByType(EVipRecordType._EVipRecordTypeExper);
                if (_loc_5)
                {
                    _loc_3 = Language.getStringByParam(35100, _loc_5);
                }
                else
                {
                    _loc_3 = "";
                }
            }
            var _loc_4:String = "";
            if (param2)
            {
                _loc_6 = Cache.instance.role.entityInfo.level;
                if (_loc_6 >= GameDefConfig.instance.getSystemOpenLevel(92))
                {
                    _loc_7 = Cache.instance.publicCache.worldLevel;
                    _loc_8 = _loc_7 - _loc_6;
                    _loc_9 = QuestionCopyConfig.instance().wordLevelAddExpArr;
                    if (_loc_8 > 0)
                    {
                        for each (_loc_10 in _loc_9)
                        {
                            
                            if (_loc_8 >= _loc_10.scoreMin && _loc_8 <= _loc_10.scoreMax)
                            {
                                _loc_4 = Language.getStringByParam(20689, _loc_10.times);
                                break;
                            }
                        }
                    }
                }
            }
            return _loc_3 + _loc_4;
        }// end function

    }
}
